package tools;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;

public class LogManager {
	private boolean writeToFile = false;
	private String dir = "C:\\timerkeeperlogs";
	private String fileStr = "";
	
	public void setFile(String fileStr){
		this.fileStr = fileStr;
	}
	
	public void writeToFile(boolean writeToFile){
		this.writeToFile = writeToFile;
	}
	
	public void printLog(String content){
		SysAlert.info("LogManager:", content);
		if(writeToFile){
			if(fileStr.length()==0){
				fileStr = "Log.txt";
			}
			WriteStringToFile(content);
		}
	}
	
	
	
    public void WriteStringToFile(String content) {
        try {
            File file = new File(dir+fileStr);
            FileUtils utils =new FileUtils();
            utils.write2SdFromInput(dir, fileStr, utils.String2InputStream(content));
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
